AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( 'shared.lua' )

local offset = 0
local UP = true

function ENT:Initialize( )

	self:SetNWBool("IsBeingEaten", false)
	self.NewAngle = 0
	self.YOffset = 20
	
	self:SetUseType(CONTINOUS_USE)
	self:SetModel(self.Model or "models/dav0r/hoverball.mdl")
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	
	self.ShadowParams = {}
	self:Activate()
	self:GetPhysicsObject():Wake()
	self:StartMotionController()
	self.Origin = false
	self.Origin2 = self.Entity:GetPos()
	
	self:SetDTFloat(0, self.EatTime)

end

function ENT:Think()

	if self:GetDTFloat(0) <= 0 then self:Remove() end

end

function ENT:PhysicsSimulate( phys, deltatime )

	if self.Origin then
	 	self:GetPhysicsObject():Wake()
		
		local x, y = self:GetPos().x, self:GetPos().y
		
	 	self.ShadowParams.secondstoarrive = 1.5
	 	self.ShadowParams.pos = Vector(self.Origin2.x, self.Origin2.y, self.Origin2.z+self.YOffset)
	 	self.ShadowParams.angle = Angle(0, self.NewAngle, 0)
	 	self.ShadowParams.maxangular = 5000
	 	self.ShadowParams.maxangulardamp = 10000
	 	self.ShadowParams.maxspeed = 1000000
	 	self.ShadowParams.maxspeeddamp = 10000
	 	self.ShadowParams.dampfactor = 0.8
	 	self.ShadowParams.teleportdistance = 200
	 	self.ShadowParams.deltatime = deltatime
		
	 	self:GetPhysicsObject():ComputeShadowControl(self.ShadowParams)
	end
	
end

function ENT:Think( )
	
	if !self.Origin then self.Origin2 = self:GetPos() self.Origin = true end


	self.NewAngle = self.NewAngle + 15
	if self.NewAngle >= 360 then self.NewAngle = 0 end
	
end

function ENT:Use( activator, caller )

end
